<% title_tag t(".Edit Doc") %>

<%= render 'form', doc: @doc %>

<%
locked_user = @doc.locked_user
%>

<% if locked_user && locked_user != current_user %>
  <details class="edit-doc-lock-overlay details-reset details-overlay details-overlay-dark" open>
    <div class="summary-overlay"></div>
    <details-dialog class="box box--overlay d-flex flex-column anim-fade-in fast">
      <div class="box-header">
        <h3 class="box-title"><%= t(".Doc current in locked") %></h3>
      </div>
      <div class="overflow-auto">
        <%= form_for(@doc, url: @doc.to_path("/lock"), method: :post, remote: true) do %>
          <div id="doc-lock-box" class="box-body overflow-auto">
            <p><strong class="text-red"><%= t(".Warning") %></strong> <%= user_avatar_tag(locked_user, style: :tiny) %> <%= user_name_tag(locked_user) %> <%= t(".in editing this document now") %></p>
            <p><%= t(".Continue edit will make conflict, do you wants continue?") %></p>
          </div>
          <div class="box-footer clearfix">
            <button type="submit" class="btn btn-danger"><%= t(".Continue edit") %></button>
            <a class="btn float-right" href="<%= @doc.to_path %>"><%= t(".Cancel") %></a>
          </div>
        <% end %>
      </div>
    </details-dialog>
  </details>
<% else %>
  <script id="edit-doc-script-lock" type="text/javascript">
    $.post("<%= @doc.to_path("/lock") %>");
  </script>
<% end %>